package com.culturesalon.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.culturesalon.dao.NoticeDAO;
import com.culturesalon.dao.NoticeDAOImpl;
import com.culturesalon.dto.Notice;
import com.culturesalon.dto.User;


/**
 * Servlet implementation class Notice
 */
@WebServlet("/notice.do")
public class NoticeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public NoticeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String id=request.getParameter("id");
		NoticeDAO noticeDAO=new NoticeDAOImpl();
		Notice notice=noticeDAO.get(Integer.parseInt(id));
		
		request.setAttribute("notice", notice);
		User user1=(User) request.getSession().getAttribute("user");
		if(user1!=null){
			request.getRequestDispatcher("gonggao.jsp").forward(request, response);
		}
		else{
			request.getRequestDispatcher("gonggao1.jsp").forward(request, response);
		}
		
		
		
	}

}
